package com.zdj.threadlocal;

import org.junit.Test;

/**
 * @author zhangdj
 * @date 2021-10-20 16:21:11
 */
public class Main {

    private ThreadLocal<Object> threadLocal = new ThreadLocal<>();

    @Test
    public void t1() {
        threadLocal.set("1");
        while (true) {

        }
    }

    @Test
    public void t2() throws Exception {
        threadLocal.set("2");
        while (true) {
            Thread.sleep(1000);
            System.out.println(threadLocal.get());
        }
    }

    @Test
    public void t3() {
        Object o = threadLocal.get();
        System.out.println(o);
    }
}
